﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using MKDiractorySearch;
using MovieModels;

namespace MK_Movie_Manager
{
    public partial class SearchedMovieFile : UserControl
    {

        public SearchedMovieFile()
        {
            InitializeComponent();
        }
        public bool IsChecked
        {
            get { return this.cbToAction.Checked; }
        }
        public string FileName
        {
            get
            {
                return this.TB_Movie_Name.Text;
            }
        }
        public string Path { get; set; }
        public SearchedMovieFile(MKFile fileName)
        {
            InitializeComponent();
            // TODO: Complete member initialization
            this.lblMovieName.Text = fileName.Name;
            this.TB_Movie_Name.Text = FormatHelper.GetFormattedMovieName(fileName.Name);
            this.lblMovieType.Text = fileName.Extension.Trim('.').ToString();
            this.lblMovieSize.Text = GetSize(fileName.Size);
            this.cbToAction.Checked = true;
            this.Path = fileName.Path;
        }

        private string GetSize(long size)
        {
            var sizes = new string[] { "KB", "MB", "GB" };
            double p = (double)size;
            if (p / 1024 < 1)
                return p.ToString("0.00") + " Byte";
            p = p / 1024;
            if (p / 1024 < 1)
                return p.ToString("0.00") + " KB";
            p = p / 1024;
            if (p / 1024 < 1)
                return p.ToString("0.00") + " MB";
            p = p / 1024;
            if (p / 1024 < 1)
                return p.ToString("0.00") + " GB";
            return p.ToString();
        }
    }
}
